import { IPSSysBICube } from './ipssys-bicube';
import { IPSSysBICubeDimension } from './ipssys-bicube-dimension';
import { IPSSysBIReportDimension } from './ipssys-bireport-dimension';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysBIReportDimensionImpl extends PSModelObjectImpl implements IPSSysBIReportDimension {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get itemTag(): string {
    return this.M.itemTag;
  }

  get itemTag2(): string {
    return this.M.itemTag2;
  }

  get itemType(): 'MEASURE' | 'DIMENSION' | 'USER' {
    return this.M.itemType;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected pssysbicubedimension: IPSSysBICubeDimension | null = null;

  getPSSysBICubeDimension(): IPSSysBICubeDimension | null {
    if (this.pssysbicubedimension != null) return this.pssysbicubedimension;
    const value = this.M.getPSSysBICubeDimension;
    if (value == null) {
      return null;
    }
    const ipssysbicube = this.getParentPSModelObject('bi.IPSSysBICube') as IPSSysBICube;
    if (ipssysbicube != null) {
      this.pssysbicubedimension = ipssysbicube.findPSSysBICubeDimension(value);
    }
    return this.pssysbicubedimension;
  }

  get psSysBICubeDimension(): IPSSysBICubeDimension | null {
    return this.getPSSysBICubeDimension();
  }

  getPSSysBICubeDimensionMust(): IPSSysBICubeDimension {
    const value = this.getPSSysBICubeDimension();
    if (value == null) {
      throw new Error('未指定立方体维度');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSSysBIReportDimensionImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'bi.IPSBIReportDimension' || cls == 'bi.IPSSysBIReportDimension') return true;
    return super.instanceof(cls);
  }
}
